package com.geek.framework.study.validate.controller;

import com.geek.framework.study.validate.domain.User;
import com.geek.framework.study.validate.service.ValidateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/validate")
public class ValidateController {

    @Autowired
    private ValidateService validateService;

    @PostMapping("/valid")
    public ResponseEntity valid(@Valid @RequestBody User user) {
        System.out.println("user = " + user);
        return ResponseEntity.ok().build();
    }


    @GetMapping("/method")
    public ResponseEntity getMessage(@RequestParam String message) {
        String msg = validateService.getMessage(message);
        return ResponseEntity.ok(msg);
    }

}
